import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ywn_app/pages/FriendPage.dart';
import 'package:ywn_app/pages/HomePage.dart';
import 'package:ywn_app/pages/MyPage.dart';
import 'contains/ThemeGlobal.dart';
import 'demo/SliverCustomHeaderDelegate.dart';

void main() {
  runApp(
      MyApp()
  );
  SystemUiOverlayStyle systemUiOverlayStyle =
      SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  SystemChrome.setEnabledSystemUIOverlays(
      [SystemUiOverlay.top, SystemUiOverlay.bottom]);
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primaryColor: themeColor,
        fontFamily: 'PingFang'
      ),
      home: Index(),
    );
  }
}

class Index extends StatefulWidget {
  @override
  _IndexState createState() => _IndexState();
}

class _IndexState extends State<Index> {
  int _page = 0;

  List<Widget> list = [
   // ListViewPulltoRefresh(),
    FriendPage(),
    HomePage(),
    /*MyPage(),*/
    CustomSliverHeaderDemo()
  ];

  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334,allowFontScaling: true)..init(context);
    return Scaffold(
      body: IndexedStack(
          index: _page,
          children: list
      ),
      bottomNavigationBar: BottomNavigationBar(
        elevation: 4,
        currentIndex: _page,
        items: [
         // BottomNavigationBarItem(icon: Icon(Icons.card_travel), title: Text('演示')),
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('首页')),
          BottomNavigationBarItem(icon: Icon(Icons.mood), title: Text('朋友')),
          BottomNavigationBarItem(icon: Icon(Icons.person), title: Text('我的')),
        ],
        selectedItemColor: themeColor,
        unselectedItemColor: Colors.black,
        selectedFontSize: 12,
        onTap: (int index) {
          setState(() {
            _page = index;
          });
        },
      ),
    );
  }
}
